package nu.aop.model;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;

public class StatisticDaoImpl implements StatisticDao{
	private SqlSessionTemplate sqlSessionTemplate;
	public StatisticDaoImpl(SqlSessionTemplate sqlSessionTemplate){
		this.sqlSessionTemplate=sqlSessionTemplate;
	}
	@Override
	public void increaseStudyHits(String id) throws Exception {
		sqlSessionTemplate.update("statistic.increaseStudyHits",id);
	}
	@Override
	public void increaseFinanceHits(String id) throws Exception {
		sqlSessionTemplate.update("statistic.increaseFinanceHits",id);
		
	}
	@Override
	public void increaseSportsHits(String id) throws Exception {
		sqlSessionTemplate.update("statistic.increaseSportsHits",id);
	}
	@Override
	public void increaseLivingHits(String id) throws Exception {
		sqlSessionTemplate.update("statistic.increaseLivingHits",id);
	}
	@Override
	public void increaseSmokingHits(String id) throws Exception {
		sqlSessionTemplate.update("statistic.increaseSmokingHits",id);
	}
	@Override
	public GroupHitsVO selectGroupHitsById(String id) throws Exception {
		return sqlSessionTemplate.selectOne("statistic.selectGroupHitsById",id);
	}
	@Override
	public void insertGroupHits(GroupHitsVO groupHitsVO) throws Exception {
		sqlSessionTemplate.insert("statistic.insertGroupHits", groupHitsVO);
	}
	/**
	  * id로 Statistic 테이블에 가장 마지막 timePosted값을 가져온다
	  */
	 @Override
	 public String selectMemeberTimePostedById(String id) throws Exception {
	  return sqlSessionTemplate.selectOne("statistic.selectMemeberTimePostedById", id);
	 }
	 
	 /**
	  * id로 Statistic 테이블에 포인트 정보를 insert
	  */
	 @Override
	 public void insertMemberPointStatistic(StatisticPointVO spvo) throws Exception {
	  sqlSessionTemplate.insert("statistic.insertMemberPointStatistic", spvo);
	 }

	 @Override
	 public String selectCurrentTime() throws Exception {
	  return sqlSessionTemplate.selectOne("statistic.selectCurrentTime");
	 }
	@Override
	public List<StatisticPointVO> selectListStatisticPoint(String id)
			throws Exception {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList("statistic.selectListStatisticPoint", id);
	}
}
